class Dish < ActiveRecord::Base
	validates_presence_of :name, :description, :image_url
	
	def delete
		delete_file(self.image_url)
		self.destroy
	end
		
  def delete_file(filename)
  	if File.exist?("#{RAILS_ROOT}/public/images/upload/#{filename}")
  		File.delete("#{RAILS_ROOT}/public/images/upload/#{filename}")
  	end
  end
  
end
